package com.example.appjava.vo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author sjw
 * @className ThreadLocalTest
 * @date 2021/12/11 14:45
 * @description: TODO
 */
public class ThreadLocalTest {
    public ThreadLocal<String> threadLocal=new ThreadLocal<String>(){
        @Override
        protected String initialValue() {
            System.out.println(1);
            return Thread.currentThread().getName();
        }
    };

    public static void main(String[] args) {
        ThreadLocalTest threadLocalTest=new ThreadLocalTest();
        System.out.println(threadLocalTest.threadLocal.get());
        System.out.println(threadLocalTest.threadLocal.get());
        System.out.println(new ThreadLocalTest().threadLocal.get());
        ExecutorService executorService = Executors.newFixedThreadPool(2);

    }
}
